package cn.com.greatwall.kafka.repository;

import java.util.List;
import java.util.Set;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import cn.com.greatwall.kafka.domain.Topic;

/**
 * @Author herw
 * @Time 2021-01-21 13:21:58
 * @Version 1.0
 * @Description: TODO(用一句话描述该文件做什么)
 */
public interface TopicRepository extends JpaRepository<Topic, Long>, JpaSpecificationExecutor<Topic> {
    /**
     * 根据Id删除
     * 
     * @param ids /
     */
    void deleteAllByIdIn(Set<Long> ids);

    /**
     * 根据名称删除
     * 
     * @param name
     */
    @Modifying
    @Query(value = "delete from mq_topic where name =?1", nativeQuery = true)
    void deleteByName(String name);
    
    /**
     * 根据 clusterId 查询
     * 
     * @param id 
     * @return /
     */
    List<Topic> findByClusterId(Long clusterId);
}
